using System;
using GameFramework.Sound;
using UnityEngine;
using Unity.VisualScripting;
using UnityGameFramework.Runtime;
using PlaySoundDependencyAssetEventArgs = UnityGameFramework.Runtime.PlaySoundDependencyAssetEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Play Sound")]
    [UnitSurtitle("Dependency Asset")]
    public sealed class PlaySoundDependencyAsset : FrameworkEventUnit<PlaySoundDependencyAssetEventArgs>
    {
        protected override int EventId => PlaySoundDependencyAssetEventArgs.EventId;
        protected override string HookName => UGFHookNames.PlaySoundDependencyAsset;
        
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SerialId
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SoundAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput SoundGroupName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput PlaySoundParams
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DependencyAssetName
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput LoadedCount
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput TotalCount
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput BindingEntity
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput UserData { get; private set; }

        protected override void Definition()
        {
            base.Definition();
            SerialId = ValueOutput<int>(nameof(SerialId));
            SoundAssetName = ValueOutput<string>(nameof(SoundAssetName));
            SoundGroupName = ValueOutput<string>(nameof(SoundGroupName));
            PlaySoundParams = ValueOutput<PlaySoundParams>(nameof(PlaySoundParams));
            DependencyAssetName = ValueOutput<string>(nameof(DependencyAssetName));
            LoadedCount = ValueOutput<int>(nameof(LoadedCount));
            TotalCount = ValueOutput<int>(nameof(TotalCount));
            BindingEntity = ValueOutput<Entity>(nameof(BindingEntity));
            UserData = ValueOutput<string>(nameof(UserData));
        }

        protected override void AssignArguments(Flow flow, PlaySoundDependencyAssetEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(SerialId, args.SerialId);
            flow.SetValue(SoundAssetName, args.SoundAssetName);
            flow.SetValue(SoundGroupName, args.SoundGroupName);
            flow.SetValue(PlaySoundParams, args.PlaySoundParams);
            flow.SetValue(DependencyAssetName, args.DependencyAssetName);
            flow.SetValue(LoadedCount, args.LoadedCount);
            flow.SetValue(TotalCount, args.TotalCount);
            flow.SetValue(BindingEntity, args.BindingEntity);
            flow.SetValue(UserData, args.UserData);
        }
    }
}